Linear Gaussian DGP
Function
#> function(n, beta, rho, sigma) {
#> cov_mat <- matrix(c(1, rho, rho, 1), byrow = T, nrow = 2, ncol = 2)
#> X <- MASS::mvrnorm(n = n, mu = rep(0, 2), Sigma = cov_mat)
#> y <- X %*% beta + rnorm(n, sd = sigma)
#> return(list(X = X, y = y))
#> }
#> <bytecode: 0x55641559b818>
Input Parameters
#> $n
#> [1] 200
#>
#> $beta
#> [1] 1 0
#>
#> $rho
#> [1] 0
#>
#> $sigma
#> [1] 1
OLS
Function
#> function(X, y, cols = c("X1", "X2")) {
#> lm_fit <- lm(y ~ X)
#> pvals <- summary(lm_fit)$coefficients[cols, "Pr(>|t|)"] %>%
#> setNames(paste(names(.), "p-value"))
#> return(pvals)
#> }
#> <bytecode: 0x5564138d8870>
Input Parameters
#> list()
Rejection Prob. (alpha = 0.1)
Function
#> function(fit_results, alpha = 0.05) {
#> group_vars <- c(".dgp_name", ".method_name")
#> eval_out <- fit_results %>%
#> dplyr::group_by(across({{group_vars}})) %>%
#> dplyr::summarise(
#> `X1 Reject Prob.` = mean(`X1 p-value` < alpha),
#> `X2 Reject Prob.` = mean(`X2 p-value` < alpha)
#> )
#> return(eval_out)
#> }
Input Parameters
#> $alpha
#> [1] 0.1
Function
#> function(fit_results, vary_params = NULL, alpha = 0.05) {
#> group_vars <- c(".dgp_name", ".method_name", vary_params)
#> eval_out <- fit_results %>%
#> dplyr::group_by(across({{group_vars}})) %>%
#> dplyr::summarise(
#> `X1 Reject Prob.` = mean(`X1 p-value` < alpha),
#> `X2 Reject Prob.` = mean(`X2 p-value` < alpha)
#> )
#> return(eval_out)
#> }
#> <bytecode: 0x556412309e58>
Input Parameters
#> $alpha
#> [1] 0.1
Function
#> function(fit_results, vary_params = NULL, alpha = 0.05) {
#> group_vars <- c(".dgp_name", ".method_name", vary_params)
#> eval_out <- fit_results %>%
#> dplyr::group_by(across({{group_vars}})) %>%
#> dplyr::summarise(
#> `X1 Reject Prob.` = mean(`X1 p-value` < alpha),
#> `X2 Reject Prob.` = mean(`X2 p-value` < alpha)
#> )
#> return(eval_out)
#> }
#> <bytecode: 0x556411f092f0>
Input Parameters
#> $alpha
#> [1] 0.1
Function
#> function(fit_results, vary_params = NULL, alpha = 0.05) {
#> group_vars <- c(".dgp_name", ".method_name", vary_params)
#> eval_out <- fit_results %>%
#> dplyr::group_by(across({{group_vars}})) %>%
#> dplyr::summarise(
#> `X1 Reject Prob.` = mean(`X1 p-value` < alpha),
#> `X2 Reject Prob.` = mean(`X2 p-value` < alpha)
#> )
#> return(eval_out)
#> }
Input Parameters
#> $alpha
#> [1] 0.1
Power
Function
#> function(fit_results, col = "X1") {
#> plt <- ggplot2::ggplot(fit_results) +
#> ggplot2::aes(x = .data[[paste(col, "p-value")]],
#> color = as.factor(.method_name)) +
#> ggplot2::geom_abline(slope = 1, intercept = 0,
#> color = "darkgray", linetype = "solid", size = 1) +
#> ggplot2::stat_ecdf(size = 1) +
#> ggplot2::scale_x_continuous(limits = c(0, 1)) +
#> ggplot2::labs(x = "t", y = "P( p-value \u2264 t )",
#> linetype = "", color = "Method")
#> return(plt)
#> }
Input Parameters
#> list()
Function
#> function(fit_results, vary_params = NULL, col = "X1") {
#>
#> if (!is.null(vary_params)) {
#> # deal with the case when we vary across a parameter that is vector-valued
#> if (is.list(fit_results[[vary_params]])) {
#> fit_results[[vary_params]] <- list_col_to_chr(fit_results[[vary_params]],
#> name = vary_params,
#> verbatim = TRUE)
#> }
#> }
#>
#> plt <- ggplot2::ggplot(fit_results) +
#> ggplot2::aes(x = .data[[paste(col, "p-value")]],
#> color = as.factor(.method_name)) +
#> ggplot2::geom_abline(slope = 1, intercept = 0,
#> color = "darkgray", linetype = "solid", size = 1) +
#> ggplot2::stat_ecdf(size = 1) +
#> ggplot2::scale_x_continuous(limits = c(0, 1)) +
#> ggplot2::labs(x = "t", y = "P( p-value \u2264 t )",
#> linetype = "", color = "Method")
#> if (!is.null(vary_params)) {
#> plt <- plt + ggplot2::facet_wrap(~ .data[[vary_params]])
#> }
#> return(plt)
#> }
#> <bytecode: 0x55641503a020>
Input Parameters
#> list()
Function
#> function(fit_results, vary_params = NULL, col = "X1") {
#>
#> if (!is.null(vary_params)) {
#> # deal with the case when we vary across a parameter that is vector-valued
#> if (is.list(fit_results[[vary_params]])) {
#> fit_results[[vary_params]] <- list_col_to_chr(fit_results[[vary_params]],
#> name = vary_params,
#> verbatim = TRUE)
#> }
#> }
#>
#> plt <- ggplot2::ggplot(fit_results) +
#> ggplot2::aes(x = .data[[paste(col, "p-value")]],
#> color = as.factor(.method_name)) +
#> ggplot2::geom_abline(slope = 1, intercept = 0,
#> color = "darkgray", linetype = "solid", size = 1) +
#> ggplot2::stat_ecdf(size = 1) +
#> ggplot2::scale_x_continuous(limits = c(0, 1)) +
#> ggplot2::labs(x = "t", y = "P( p-value \u2264 t )",
#> linetype = "", color = "Method")
#> if (!is.null(vary_params)) {
#> plt <- plt + ggplot2::facet_wrap(~ .data[[vary_params]])
#> }
#> return(plt)
#> }
#> <bytecode: 0x556416160a70>
Input Parameters
#> list()
Function
#> function(fit_results, vary_params = NULL, col = "X1") {
#>
#> if (!is.null(vary_params)) {
#> # deal with the case when we vary across a parameter that is vector-valued
#> if (is.list(fit_results[[vary_params]])) {
#> fit_results[[vary_params]] <- list_col_to_chr(fit_results[[vary_params]],
#> name = vary_params,
#> verbatim = TRUE)
#> }
#> }
#>
#> plt <- ggplot2::ggplot(fit_results) +
#> ggplot2::aes(x = .data[[paste(col, "p-value")]],
#> color = as.factor(.method_name)) +
#> ggplot2::geom_abline(slope = 1, intercept = 0,
#> color = "darkgray", linetype = "solid", size = 1) +
#> ggplot2::stat_ecdf(size = 1) +
#> ggplot2::scale_x_continuous(limits = c(0, 1)) +
#> ggplot2::labs(x = "t", y = "P( p-value \u2264 t )",
#> linetype = "", color = "Method")
#> if (!is.null(vary_params)) {
#> plt <- plt + ggplot2::facet_wrap(~ .data[[vary_params]])
#> }
#> return(plt)
#> }
#> <bytecode: 0x556416677928>
Input Parameters
#> list()
Rejection Prob. (alpha = 0.1) Plot
Function
#> function(eval_results, vary_params = NULL,
#> alpha = 0.05) {
#> eval_results <- eval_results$`Rejection Prob. (alpha = 0.1)`
#> if (is.list(eval_results[[vary_params]])) {
#> # deal with the case when we vary across a parameter that is vector-valued
#> eval_results[[vary_params]] <- list_col_to_chr(eval_results[[vary_params]],
#> name = vary_params,
#> verbatim = TRUE)
#> }
#> plt <- ggplot2::ggplot(eval_results) +
#> ggplot2::aes(x = .data[[vary_params]], y = `X1 Reject Prob.`,
#> color = as.factor(.method_name),
#> fill = as.factor(.method_name)) +
#> ggplot2::labs(x = vary_params,
#> y = sprintf("Rejection Probability (alpha = %s)", alpha),
#> color = "Method", fill = "Method") +
#> ggplot2::scale_y_continuous(limits = c(0, 1))
#> if (is.numeric(eval_results[[vary_params]])) {
#> plt <- plt +
#> ggplot2::geom_line() +
#> ggplot2::geom_point(size = 2)
#> } else {
#> plt <- plt +
#> ggplot2::geom_bar(stat = "identity")
#> }
#> return(plotly::ggplotly(plt))
#> }
#> <bytecode: 0x55641464eab0>
Input Parameters
#> $alpha
#> [1] 0.1
Function
#> function(eval_results, vary_params = NULL,
#> alpha = 0.05) {
#> eval_results <- eval_results$`Rejection Prob. (alpha = 0.1)`
#> if (is.list(eval_results[[vary_params]])) {
#> # deal with the case when we vary across a parameter that is vector-valued
#> eval_results[[vary_params]] <- list_col_to_chr(eval_results[[vary_params]],
#> name = vary_params,
#> verbatim = TRUE)
#> }
#> plt <- ggplot2::ggplot(eval_results) +
#> ggplot2::aes(x = .data[[vary_params]], y = `X1 Reject Prob.`,
#> color = as.factor(.method_name),
#> fill = as.factor(.method_name)) +
#> ggplot2::labs(x = vary_params,
#> y = sprintf("Rejection Probability (alpha = %s)", alpha),
#> color = "Method", fill = "Method") +
#> ggplot2::scale_y_continuous(limits = c(0, 1))
#> if (is.numeric(eval_results[[vary_params]])) {
#> plt <- plt +
#> ggplot2::geom_line() +
#> ggplot2::geom_point(size = 2)
#> } else {
#> plt <- plt +
#> ggplot2::geom_bar(stat = "identity")
#> }
#> return(plotly::ggplotly(plt))
#> }
#> <bytecode: 0x556413948228>
Input Parameters
#> $alpha
#> [1] 0.1
Parameter Values
#> $dgp
#> $dgp$`Linear Gaussian DGP`
#> $dgp$`Linear Gaussian DGP`$beta
#> $dgp$`Linear Gaussian DGP`$beta[[1]]
#> [1] 1 0
#>
#> $dgp$`Linear Gaussian DGP`$beta[[2]]
#> [1] 1.0 0.5
#>
#> $dgp$`Linear Gaussian DGP`$beta[[3]]
#> [1] 1 1
#>
#> $dgp$`Linear Gaussian DGP`$beta[[4]]
#> [1] 1.0 1.5
#>
#> $dgp$`Linear Gaussian DGP`$beta[[5]]
#> [1] 1 2
#>
#>
#>
#>
#> $method
#> list()
Parameter Values
#> $dgp
#> $dgp$`Linear Gaussian DGP`
#> $dgp$`Linear Gaussian DGP`$rho
#> [1] 0.0 0.2 0.5 0.9
#>
#>
#>
#> $method
#> list()
Parameter Values
#> $dgp
#> $dgp$`Linear Gaussian DGP`
#> $dgp$`Linear Gaussian DGP`$sigma
#> [1] 1 2 4 8
#>
#>
#>
#> $method
#> list()